package com.quanshu.change.person.view;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.quanshu.change.person.adapter.SeckillGoodsSellViewPagerAdapter;
import com.quanshu.exchange.R;
import com.quanshu.exchange.support.utils.RxViewHelper;
import com.quanshu.exchange.ui.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class SeckillGoodsSellActivity extends BaseActivity {

    @BindView(R.id.back)
    LinearLayout back;
    @BindView(R.id.title)
    RelativeLayout title;
    @BindView(R.id.title_bar)
    TabLayout titleBar;
    @BindView(R.id.viewPager)
    ViewPager viewPager;
    private List<Fragment> fragmentList;
    private SeckillGoodsSellViewPagerAdapter seckillGoodsSellViewPagerAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_seckill_goods_sell);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        RxViewHelper.getInstance().clicks(back, aVoid -> {
            finish();
        });
        fragmentList = new ArrayList<>();
        fragmentList.add(SeckillGoodsGetFragment.newInstance());
        fragmentList.add(SeckillGoodsGet1Fragment.newInstance());
        fragmentList.add(SeckillGoodsGet2Fragment.newInstance());
        List<String> stringList = new ArrayList<>();
        stringList.add("寄售中");
        stringList.add("寄售成功");
        stringList.add("寄售失败");
        seckillGoodsSellViewPagerAdapter = new SeckillGoodsSellViewPagerAdapter(getSupportFragmentManager(), fragmentList, stringList);
        viewPager.setAdapter(seckillGoodsSellViewPagerAdapter);
        titleBar.setupWithViewPager(viewPager);
    }
}
